import request from '@/utils/request';
import { useUserStore } from '@/stores/modules/user';

const userStore = useUserStore();
export const reqUserLogin = (data) => {
    return  request({
        url: '/login',
        method: 'post',
        data
    })
}
export const reqGetUserInfo = () => {
    return  request({
        url: '/user_info',
        params:{
            Authorization:"Bearer "+userStore.token
        }
    })
}

export const reqGetUserList = (pageNum,pageSize) => {
    return  request({
        url: '/user_list',
        params:{
            pageNum,pageSize,
        }
    })

}
export const reqChangeStatus = (id,status) => { 
    return  request({
        url: '/change_status',
        params:{
            id,status
        }
    })

}

export const reqDeleteUser = (userId) => { 
    return  request({
        url: '/delete_user',
        params:{
            userId
        }
    })
}
export const reqUpdateUser = (userData) => { 
    return request({
        url: '/update_user',
        method: 'POST',
        data: { id: userData.id, ...userData }, // 确保 ID 包含在请求体中
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        },
    });
};

export const reqAddUser = (userData) => { 
    return request({
        url: '/add_user',
        method: 'POST',
        data: userData,
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        },
    });
    };
